﻿namespace ApiTemplate.DAL
{
    /// <summary>
    /// 用户相关数据访问层
    /// </summary>
    public class UserInfoDAL : Base.BaseDAL, IUserInfoDAL
    {
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="input">用户名</param>
        /// <returns>前端需要的用户信息</returns>
        public UserLoginOutput UserLoginAsync(UserLoginInput input)
        {
            return DbContext.Queryable<UserInfo>()
                .Where(x => x.UserName == input.UserName && x.PassWord == input.PassWord)
                .Select(x => new UserLoginOutput()
                {
                    Avatar = x.Avatar,
                    UserName = x.UserName,
                    Id = x.Id,
                    OrgId = x.OrgId,
                    Resume = x.Resume,
                    Sex = x.Sex
                }).First();
        }
    }
}
